#include "NxModelServiceFactory.h"
#include "NxModelService.h"


NJGIS::SERVICE::INjModelService* NJGIS::SERVICE::NjModelServiceFactory::createModelServiceByJSON( Json::Value &jMs, const char* ip, int port)
{
	std::string oid = jMs["_id"].asString();
	std::string name = jMs["ms_model"]["m_name"].asString();
	std::string type = jMs["ms_model"]["m_type"].asString();
	std::string url = jMs["ms_model"]["m_url"].asString();
	std::string pid = jMs["ms_model"]["p_id"].asString();
	std::string mid = jMs["ms_model"]["m_id"].asString();
	bool registered = jMs["ms_model"]["m_register"].asBool();
	std::string des = jMs["ms_des"].asString();
	std::string version = jMs["mv_num"].asString();
	NJGIS::SERVICE::NjPlatform platform = (NJGIS::SERVICE::NjPlatform)jMs["ms_platform"].asInt();
	std::string deploymentTime = jMs["ms_des"].asString();
	std::string img = jMs["ms_des"].asString();
	std::string delpoyorname = jMs["delpoyorname"].asString();
	std::string delpoyoremail = jMs["ms_des"].asString();
	NJGIS::SERVICE::NjModelServiceStatus status =  (NJGIS::SERVICE::NjModelServiceStatus)jMs["ms_status"].asInt();
	NJGIS::SERVICE::NjModelServiceLimitation limit = (NJGIS::SERVICE::NjModelServiceLimitation)jMs["ms_limited"].asInt();
	NJGIS::SERVICE::NjModelServicePermission permission = (NJGIS::SERVICE::NjModelServicePermission)jMs["ms_permission"].asInt();


	INjModelService* pMs = new NjModelService(oid.c_str(), name.c_str(), type.c_str(), url.c_str(), pid.c_str(), 
		mid.c_str(), registered, des.c_str(), version.c_str(), platform, deploymentTime.c_str(), img.c_str(), 
		delpoyorname.c_str(), delpoyoremail.c_str(), status, limit, permission, ip, port);
	return pMs;
}
